package proxy;

/**
 * 被代理类.
 * <p>
 * 假设被代理类的初始化时间很长.
 *
 * @author GongXincheng
 * @since 2019-09-17 15:07
 */
public class RealSubject implements Subject {

    RealSubject() {
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            System.out.println("RealSubject 初始化失败.");
            throw new RuntimeException(e);
        }
    }

    @Override
    public void speak(String message) {
        System.out.println("RealSubject：" + message);
    }

    @Override
    public void run() {
        System.out.println("RealSubject is running");
    }

    @Override
    public void sing() {
        System.out.println("RealSubject is singing");
    }
}
